home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr33
/
fca28.zip
/
FCA.DOC
next >
Wrap
Text File
|
1993-04-28
|
32KB
|
762 lines
FCA 2.8
Resident Floating Point Scientific Calculator
by
Bob Eyer
[73230,2620]
Apr 28, 1992
┌────────────────────────────────────────────────────────────────┐
│ │
│ Like the idea of a BBS program that works at a basic │
│ level with no configuration at all--a miniature BBS │
│ which can be made as sophisticated as you like, but │
│ which can be run as a simple utility if you forget how │
│ to use it? Try HOSP. Lots of people like it. And you │
│ can have a copy for only $25 (the basic shareware │
│ charge plus $5). That contribution pays for HOSP as │
│ well as some four dozen other utilities. See SHARE.TXT │
│ for details. For preview, see HOST30.ZIP in IBMBBS. │
│ │
└────────────────────────────────────────────────────────────────┘
Syntax
------
FCA [/U] Hotkey: Rightshift-/
Modes
-----
places COLOR y RAD/DEG TWO/NAP/TEN STUF/D DMS/NODMS
Review
------
ST Registers: E PI A B C F K L M N Q R S X Y Z
Data entry areas
----------------
ADD MEAN REGRESSION
Binary ops
----------
+ - * / ^ CO PE
Unary operations
----------------
SQ/SQRT EXP/LOG SIN/ASN COS/ACS TAN/ATN SINH COSH
TANH ! HEX/DEC X= Y=
Probability
-----------
BIN NORM POIS STUD
See the note about Errors below.
Changes in FCA 2.8
------------------
- Addition of Hex, decimal conversions.
- Bug in data entry areas which affected the sign of entered
numbers now removed.
- Exponential notation now uses 'D' rather than 'e'.
- FCA 2.8 is essentially FCAP 1.3; latter pgm no longer offered
as retail enhancement of FCA.
INTRODUCTORY NOTE: FCA is a floating point companion alternative
to CA (see program listing in Shareware Notice above), which is
restricted to four function fixed point arithmetic. FCA supports
at least 30 functions. CA uses about 12K of memory; FCA uses
about 40K. In the 40K class, competing floating-point calculators
offer far fewer functions.
FCA is not a general formula evaluator. If you need to do many
different kinds of calculations on the same text in one shot, it
may be more appropriate to use Lotus 1-2-3 or similar, print
results as a file, edit, and then insert into your text. FCA,
however, does provide a simple means of re-using input data for
subsequent calculations (see section below about Automatic
Store/Recall and also the discussion about register operations).
Also, FCA provides a method of adding many numbers before
injecting the sum to text (See Special Accumulator section below).
FCA's floating point emulator will take advantage of the
coprocessor, if one is installed. This advantage is noticeable
primarily with regard to the probability functions. The slowest
and least accurate function is the Student probability integral,
which may require up to 8 seconds and beyond to find results
arising from certain rare combinations of input variables on a 386
machine WITH installed 80387. This function works up to 60 times
more slowly when run on a machine lacking a coprocessor. While
the transcendentals generally have an accuracy of the order of 12
decimal places, Gosset's Student t is generally accurate to only
5. See below about the STUD function.
FCA's real number range, apart from sign, is roughly between
1D-294 and 1.7D+308. This is much larger than is possible in the
companion program CA, and is also larger than the usual range for
many scientific calculators.
FCA does not provide a menu or picture of a calculator - so as to
avoid obscuring portions of the underlying editing application,
and to avoid requiring the user to employ only 25 x 80 screens
(some TSR calculators require this, to make use of Line 25 for
calculator monitoring). FCA responds equally well in 50 x 80 or
44 x 132 video environments; generally, it is indifferent to the
manner in which the video raster is defined.
FCA is designed to respond just to the hotkey, which provides
merely a 'calculation window', in which the user enters his
calculations or mode changes. Hitting ENTER after supplying a
calculation or mode change to the window, simply executes the job
and returns to the application. Where a result is generated, it
is pasted directly to the underlying application where the cursor
was last located.
In examples seen below, EACH calculation or mode change is
preceded by invoking the hotkey. This, however, does not apply to
special areas dealing with more complex problems, such as MEAN and
REGRESSION.
FCA is also designed to return the cursor to the initial position
in the main calculation window, to permit making mode adjustments
without line skipping. Once a task is completed, you may exit the
window merely by hitting ENTER one additional time or by using the
spacebar to delete the window. The old window always disappears
in an editing environment after the result is injected to the
text, but mode change information will, in general, remain.
Modes/review
------------
FCA provides 6 groups of mode selections - number of decimal
places to which to round results, colour of calculation window,
whether to use Radian or Degree measure, what base to use for the
EXP and LOG operations, whether to echo the result to display or
paste to text, and whether to use DMS format in trig calculations.
The current mode situation may be viewed simply by entering ST in
the calculation window (ST is short for 'status').
Mode changes are entered directly in the calculation window and
the new mode specs are resummarised in the calculation window,
just as though ST had been issued.
x
Entry merely of a number, such as 5, will cause FCA to operate so
as to round all results to, say, five decimal places. Entry of 0
means that no formatting will occur. The default value is 0.
COLOR y:
Entry of 'COLOR 30' will cause the calculation window to have a
bright yellow foreground and a blue background. For colour
details see below. The default colour scheme is black on white
(112). Color 0 automatically converts to 112, so as to avoid
black on black.
RAD/DEG:
Entry of RAD in the window causes FCA to assume all angles entered
as arguments in trig functions are in radian measure. Entry of
DEG puts FCA into Degree mode. The default is Degree mode.
TWO/NAP/TEN:
FCA supports three bases for use with the LOG or EXP functions.
TWO means base 2; NAP is short for the Napierian base or base e
(e=2.718...); and TEN means base 10. The default is base e.
STUF/D:
STUF means stuff the result to the underlying application, and D
means display only at TSR video level.
Register operations
-------------------
FCA supports pasting 11 registers direct to text. For example,
after invoking the hotkey, we simply enter
e [= 2.7182818284590
(the use of the left bracket here merely signifies that the result
appears at the underlying application, not at TSR level)
In addition, the user may simply enter A, B, or C to examine the
last value stored in FCA's "store/recall" facilities (see below),
as well as the general storage register X, and the statistics
registers.
Binary operations
-----------------
FCA supports seven two-variable ('binary') operations: + - * / ^
CO PE, or add, subtract, multiply, divide, raise to a power,
combinations and permutations, respectively. For example,
1991-1917 [= 74
7D-6+3D-4 [= 0.000307
When entering exponentially formatted numbers one must specify a
sign (+ or -) immediately after the 'D' symbol. FCA automatically
distinguishes between the sign of an exponent and an addition or
subtraction operation between two numbers.
Additional examples:
35/34 [= 1.0294117647058
35*34 [= 1190
35^34 [= 3.150021D+52 (6 places)
10 CO 4 [= 210 (210 combinations of 10 things
taken 4 at a time)
Unary operations
----------------
FCA also supports 10 unary transcendental functions, grouped by
inverses, as well as three hyperbolic functions, and the factorial
function. Here, a blank must separate the name of the operation
and the number which the operation takes as its argument.
Examples,
! 6 [= 720 (factorial 6)
HEX 12000 [= 2EE0
DEC 2EE0 [= 12000
SIN 45 [= 0.7071067811865
COS 1 [= 0.9998476951563
LOG 2 [= 0.6931471805599
EXP 1 [= 2.7182818284590
SQRT 2 [= 1.4142135623731
If you wish to use Base 10 logarithms, just enter TEN in the
window, and then
LOG 2 [= 0.3010299956639
Note: the EXP function is in fact an antilog function, since it is
subject to the same range of base changes as is the LOG function.
This may be inconvenient to some users who assume that the
exponential function must always have base e, but implementing a
separate antilog function seemed, in the circumstances, merely to
be useless duplication of what is, essentially, a quite flexible
function.
The internal setup for the hyperbolic functions is the same as for
the trig functions. If you select DEGree mode, FCA will convert
your degree measure into the radian equivalent before calculating
the function. If you select RADian mode, FCA will do no such
conversion, but will inject your argument directly to the
function.
If DMS is selected, FCA will convert decimal degrees to degrees,
minutes and seconds and set places to 6.
Automatic store/recall
----------------------
If you are doing several calculations which involve use of the
same term, you may reduce typing further by using variables.
Calculation window variables are A, B, and C. The first time you
execute a calculation with numbers, the first number is always
stored into A, the second number into B, and the result into C.
These values can be re-used, simply by employing these variables
in subsequent calculations [except, of course, for the fact that,
as each new calculation is done, the value of C will be updated
with the new result].
Example (after entering 3 in the window):
Suppose we wish to perform the following calculations -
34.21102 x 435, and
34.21102 / 355.5
Here, each calculation uses the same initial term. We proceed as
follows, each time by hitting Rightshift-slash, and entering the
calculation shown:
34.21102 * 435 [= 14881.794
a/355.5 [= 9.623D-02
The second calculation above could be repeated merely by entering
a/b
The user may also proceed to obtain results for the other three
operations, using the same numbers, as follows:
a*b [= 12162.018
a+b [= 389.711
a-b [= -321.289
The output C-variable can also be used in calculations. For
example, we may first calculate with no scientific notation
2/3 [= 0.667
Here, A = 2, B = 3, and C is the result in brackets. Now, if we
multiply the result C by 3, we should get back the numerator A:
C * 3 [= 2.000
This example illustrates the fact that FCA, like handheld
calculators with the store/recall function, stores results in a
separate register before rounding. It is this separate register
that is used for input, when the user employs C in a
calculation. [otherwise, the user might get back 2.001].
This type of 'result protection' on use of a previous result is
not, however, found in most TSR calculators.
All these remarks apply also to FCA's trig functions. For
example (using 5 decimal places),
SIN 89 [= 0.99985
We may now get back the value of the argument, simply by
performing the inverse (ARCSINE or ASN) on the result:
ASN C [= 89.00000
The same principle also works with squares and squareroots, as
well as logs and exponentials. For example,
LOG 2 [= 0.69315
but the argument '2' may be had by performing the inverse on the
result:
EXP C [= 2.00000
You may also store a previous input or result into either of the
extra storage registers X or Y. Just use, for example,
X= C or Y = B
to store the value of C into X or B into Y. Note that FCA is
indifferent on whether the entry formula is 'X=C' or 'X = C'. X
may be recalled simply by entering X by itself, or by using it as
an argument in any function.
MEAN (Total, Mean and Standard deviation)
-----------------------------------------
Entry of the keyword MEAN in the calculation window will transfer
control to a special area of FCA which displays the following type
of prompt:
X>
Numbers entered at this prompt are totalled and in passing FCA
also computes the mean and standard deviation for all numbers
entered, displaying these results in the stated order to the left
of the prompt.
If the next number in the series is the same as the previous one,
you may simply enter X at the prompt; FCA interprets X in the MEAN
window as the value last entered. The same principle applies
where the user wishes merely add the previous total to itself: use
the result register C.
The data displayed to the left of the prompt are displayed as
rounded to a minimum of 3 places.
When finished entering data, simply hit the Esc key to paste the
Total to the underlying application. The other data are available
by entering the following variable names:
C - Total
M - Mean
S - Standard deviation
N - Number of data entered.
F - Degrees of freedom (for MEAN calculations this will be
N - 1).
The main result, the total, may be accessed by using register C.
The values listed above may be used, for example, in the Normal
distribution to obtain automatic calculation of a z-score (see
below).
For the interest of statistics people, the definition of standard
deviation used in FCA assumes the "n - 1" basis. That is, it is
based on multiplying the the root mean square of the data by the
square root of the ratio of N to N - 1. The purpose of the n-1
basis is to obtain a more realistic value for the standard
deviation in small sample applications than is possible with a
mere variance calculation.
The value of this routine is primarily to obtain quick results on
small amounts of data found directly on the screen in the
underlying application. If you have a large job to do, involving
many points, your best bet is to use a large program such as LOTUS
1-2-3, not a small program like FCA.
REGRESSION (regression analysis)
--------------------------------
Entry of the keyword REGRESSION in the calculation window will
transfer control to the REGRESSION area of FCA.
Here, the prompt will change between
X>
and
Y>
and FCA will issue a beep to the speaker each time a Y value is
entered. Three running results are displayed to the left of the
prompt: The Galton-Edgeworth correlation coefficient, the
y-intercept of the regression line, and the slope of that line.
The previous value of X may be entered at either prompt by using
X, and the previous value of Y may be entered at either prompt by
using Y. If you enter C (the result register) the current
correlation coefficient will be entered at the prompt in
question. Avoid, unless you really want to do that.
But otherwise, operation of the REGRESSION area is similar to that
in MEAN.
On use of Esc to exit, FCA will paste the correlation coefficient
to the underlying application. To paste the y-intercept, use K;
and to paste the slope, use L. The regression line has the
standard form,
Y = K + LX
As usual, N is the number of pairs of data entered in the
REGRESSION window. The correlation coefficient may be obtained by
entering R.
F, the number of degrees of freedom, is also calculated by FCA,
and in the REGRESSION window, will always be set to N - 2.
BIN
---
This function returns the cumulative binomial probability of the
occurrence of X or fewer events in a sample of size N, where the
probability of a single event is Q, as well as the point
probability in register Y. The syntax is
BIN X N Q
corresponding to the summation of all values of the binomial
frequency distribution for occurrences ranging between 0 and X.
Taking an example from Spiegel's Statistics (Schaum Outline
Series, p 127), find the probability that at most 2 bolts (i.e.
either 0, 1, or 2) will be defective in a sample of 4 taken from a
production process in which 20% of all bolts produced are
defective. Here, we use
BIN 2 4 0.2 [= 0.9728
the same answer given by Spiegel.
The probability that exactly 2 bolts will be defective in this
problem is obtained merely by entering the Y register
Y [= 0.1536
POIS
----
This is the Poisson cumulative probability of the occurrence of X
or fewer events in a sample of size N, where the probability of a
single event is Q - using same syntax as BIN:
POIS X N Q
The 'integration' logic used by FCA here is the same as for the
binomial distribution. That is, the result found is the summation
of the individual Poisson probabilities from 0 to X. The point
probability is found in register Y.
The primary reason why this distribution is needed to supplement
the Binomial, is that the latter has a restricted range, owing to
the fact that it uses the factorial function to operate on the
sample size. This function explodes beyond the number range
intelligible to FCA for arguments larger than 170. The Poisson
distribution also uses the factorial function, but only on the
value of X. It is therefore capable of dealing with very large
sample sizes. The disadvantage of the Poisson is that it is only
an approximation to the Binomial.
Using another example out of Spiegel's text, we may find the
probability that more than 2 individuals out of a sample of 2000
will suffer a bad reaction from a certain injection, if the
probability that any individual will suffer is 0.001. This
problem is clearly beyond the capabilities of the binomial
distribution. The problem is solved first by finding the
probability that at least 2 will suffer. This is:
POIS 2 2000 0.001 [= 0.6767
The probability that more than 2 will suffer is obviously 1 minus
this result:
1 - C [= 0.3233
which is the same as Spiegel's result.
The probability that exactly 2 persons will suffer in this problem
is found in register Y:
Y [= 0.2707
NORM
----
The syntax for the normal probability is
NORM [X M S F] | [Z]
The form here indicates two modes of data entry; one which
involves inputting the sample mean X, the population mean M, the
sample standard deviation S, and the degrees of freedom F
associated with that sample - or simply the z-score. The value of
F should be equal to N - 1; that is, it should be one minus the
sample size. FCA will automatically calculate the appropriate
z-score if the first data entry method is used. The result is
found in register Z.
The terminology used here is compatible with the terminology used
in the MEAN section of FCA. Since FCA only uses the absolute
value of the z-score to calculate the probability of the null
hypothesis, it does not matter whether MEAN is used to compute
population or sample means.
Thus, after entering the sample in MEAN, the user may exit and
test a particular value of X, say 5, against those results by
entering
NORM 5 M S F
FCA will pick up the values of M, S, F and proceed to calculate
the z-score for the X-value 5. The result returned in C (and
pasted to text, if STUF mode is active) is the probability of the
null hypothesis - that is, the 'one-tailed' cumulative Normal
probability associated with values of X equal to or greater than
5.
If only one parameter is entered, NORM assumes that this value is
the raw z-score. For example, the one-tailed Normal probability
for a z-score of 1.96 is:
NORM 1.96 [= 2.500D-02
which checks exactly with any standard table of Normal
probabilities. 1.96 will be recognised by statisticians as the
usual z-score associated with defining a two-tailed 95% confidence
interval about a mean [2.500e-02 = 1 - 0.95/2].
The Normal ordinate for the input value of 1.96 is available in Y:
Y
STUD
----
The Normal distribution is not very useful except on large
samples, for which reason the Student distribution was developed
earlier this century by Gosset. The syntax is -
STUD [X M S F] | [Z F]
Same remarks for these variables and their purpose as given above
for NORM. Note that, if the calculation of the t-score is avoided
and direct entry is desired, the user must enter degrees of
freedom F along with the score.
For example, if the t-score is 12.706 based on a sample size only
two data, so that there is only 1 degree of freedom, then the
probability of the null hypothesis is
STUD 12.706 1 [= 2.500D-02
which agrees exactly with statistical tables on the Student
distribution.
FCA does not yet support recovery of the Student ordinate values.
The point about the importance of large samples for the Normal
distribution may be seen by noting how many degrees of freedom are
necessary to bring the Student probability into line with the
Normal, using a constant score of 1.96. This can be seen in the
following brief chart:
Z = 1.96
Degrees of freedom Student probability
------------------ -------------------
1 0.150
10 3.922D-02
30 2.967D-02
100 2.639D-02
500 2.528D-02
5000 2.503D-02
Note how the Student probability converges to the Normal as very
large amounts of data are used to calculate the sample mean. Note
also the probability with a sample size of 31 (F = 30): the value
there is close enough to the Normal value of 2.500e-02 to let the
Normal present a reasonably accurate picture of a two-tailed 95%
confidence interval on that sample size. This is the reason why
most statisticians don't consider a Normal test to be good unless
the sample is based on at least 30 pieces of data.
In text editing applications, where the user is evaluating a small
number of results, say, sample sizes of the order of 3 to 12
pieces of data, and wants a quick analysis, the Normal
distribution will not be helpful at all: The Student distribution
will be required. And it is quite handy to have such a
distribution immediately accessible at the touch of a hotkey.
I have referred here to the "t-score"; but the syntax of the STUD
function uses the variable Z. This is due to the fact that FCA
uses the same definition for the standard deviation throughout all
its statistics routines, resulting in the fact that the z-score
and the t-score use the same formulas. This being the case, it
was not necessary to distinguish a "T" variable for separate use
with the Student distribution.
Wait time
---------
The Student integral is a relatively complex and slowly converging
infinite series, and so, certain combinations of values will cause
FCA to display the message
Wait ...
for an appreciable length of time. This means that the integral
is being calculated. As stated above in the introductory portion
of this file, FCA will take full advantage of a numeric
coprocessor, if one is installed. Experiment shows that Student
probability calculations run between 30 and 60 times faster when
when there is an installed coprocessor.
Normally, this wait time problem is not significant. But for very
large t-scores and small values of F, execution time for the
Student probability may prove to be substantial, even for fast
machines. For example,
STUD 64 1 [= 4.973D-03
requires 8 seconds on a 20 Mhz 386/387 machine. On a 486 machine,
the expectation is that this result would require somewhat less
than 2 seconds, since all such machines have numeric coprocessor
capability built-in.
On a 6 MHz AT without coprocessor, however, this calculation will
require more than 22 MINUTES.
So, if you see 'Wait ...' just wait: your machine is NOT hung.
And avoid Z values substantially larger than 10, unless you have a
coprocessor, or are prepared to wait for the result. Execution
time rises about as the square of Z and drops in rough linear
proportion to the value of F.
Nearly always, however, the user will not be considering such
large t-scores and will have samples which are larger than just
two pieces of data (1 degree of freedom). For example, a t-score
of 2.78 based on a calculated mean of a sample of size 5 -
STUD 2.78 4 [= 2.491D-02
executes virtually instantaneously on a 386/387, and requires
about 3 seconds on a 6 MHz AT without coprocessor.
Prompt Colour
-------------
As stated above, to change the colour of the calculation window,
simply enter
COLOR x
in the window, where x is a COLOR number. The default is 112,
which describes black foreground on a white background. 0 is
impossible (black on black), and so FCA converts that number to
112 automatically. Foreground and Background colours may be
determined by using the following table:
Back Fore Bright Fore
---- ---- -----------
Black 0 0 8
Blue 16 1 9
Green 32 2 10
Cyan 48 3 11
Red 64 4 12
Magenta 80 5 13
Brown 96 6 14
White 112 7 15
The correct COLOR number is found merely by adding the Foreground
number to the Background number desired. For example, Bright
Green on Blue background is 10 + 16 = 26.
Avoid setting COLOR above 127. Values above that limit will
produce blinking displays.
In my estimation the COLORs best for the eye are 10, 11, 14, 15,
26, 27, 30, 31, 74, 75, 78, 79 and 112. But you may have other
ideas. Example,
COLOR 75
sets the window to Bright Cyan on a Red background.
Errors
------
FCA supports error reports as follows -
xyz: illegal - This message occurs where your entered
instruction, 'xyz', is not recognised by
FCA. For example, 'TAN89' is illegal;
should be 'TAN 89'.
Read examples in documentation above to
be sure you understand how to enter
expressions.
Illegal X setting - This means that you have tried to save
the value of unsupported register into
X. The supported registers are listed
on the help screen.
Zero divide error - Attempt to divide by zero. This can be
an explicit mistake, like '5 / 0', or it
may be an attempt to calculate the value
of a unary function which divides two
other functions to obtain its result.
For example, the TAN, or Tangent of an
angle, is really the ratio of the Sine
and the Cosine of that angle; but the
Cosine of 90 degrees is zero, so trying
to find the Tangent of 90 will generate
this error.
Negative base error - You tried raising a negative number to a
power (cannot be done on real numbers).
Negative argument error - You tried taking the LOG of a negative
number (cannot be done on real numbers).
FCA also adds numerous other specific error message readouts,
providing diagnostics on values of special variables, especially
in reference to the probility and statistics functions. These are
all self-explanatory.
----------------------
End of documentation